/*
 * @(#)Constants.java 1.0 2005-3-2
 * Copyright 2005 VandaGroup, Inc. All rights reserved.
 */
package com.vanda.util;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
/*******
 * 类说明:
 * 常量类
 * <P>@author 蒋勇
 * <P>@version 1.0 2005-3-2
 */
final public class Globals {
	private static Map cache = null;
	static {
		try {
			ResourceBundle resources = ResourceBundle.getBundle("SystemConfig");
			Enumeration enuKey = resources.getKeys();
			cache = Collections.synchronizedMap(new HashMap());
			while (enuKey.hasMoreElements()) {
				String strKey = (String) enuKey.nextElement();
				String strValue = resources.getString(strKey);
				int index = strValue.indexOf("#");
				if (index != -1) {
					strValue = strValue.substring(0, index).trim();
				}
				cache.put(strKey.trim().toLowerCase(), strValue);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static String[] ReportRunFlag =
		{ "Wait", "Executing", "Done", "Exception", "Empty" };
	//报表运行类型
	public final static String ReportRunFlag_Wait = "0"; //等待
	public final static String ReportRunFlag_Executing = "1"; //运行
	public final static String ReportRunFlag_Done = "2"; //完成
	public final static String ReportRunFlag_Exception = "3"; //异常
	public final static String ReportRunFlag_Empty = "4"; //结果为空
	public static final int REPORT_COUNT_MAX =
		getIntValue("huawei.cfi.report.countMax");
	//报表数量
	public static final int REPORT_DAEMONSPANWN_SLEEP =
		getIntValue("huawei.cfi.report.spanwnSleep");
	//报表子线程空闲时休眠时间（毫秒）
	public static final int REPORT_DAEMON_SLEEP =
		getIntValue("huawei.cfi.report.sleep");
	//报表主线程检测死掉的子线程的时间间隔（毫秒）
	public final static String REPORT_TMPPOSITION =
		getValue("huawei.cfi.report.templetPath");
	//报表模板文件路径
	public final static String REPORT_XLSURL =
		getValue("huawei.cfi.report.templetPath");
	//报表生成excel文件路径
	public static final String QUEUE_FLAG_WAIT = "0"; //等待处理
	public static final String QUEUE_FLAG_EXECUTE = "1"; //处理中
	public static final String QUEUE_FLAG_DONE = "2"; //处理完成
	public static final String QUEUE_FLAG_EXCEPTION = "3"; //异常中止
	public static final long INVOICE_TYPE_CREDITNOTE = 3; // 贷项发票的发票类别
	// 
	public static final String DATE_PATTERN = "yyyyMMdd";
	public static final String NUMBER_PATTERN = "###,###,###,###,##0.00";
	// 
	public static final int VERIFY_CODE_LENGTH = 4; //校验码长度
	public static final int PAGEROWNUM = 10;
	// 

	// 输入页面 跳转到 选择页面 时，在session中保存数据的key
	public static final String SESSION_KEY_FORMVALUE = "session.key.form_value";
	public static final String REQUEST_KEY_SELECTDATA =
		"request.key.selectdata";
	public static final String SESSION_KEY_SELECTDATA =
		"session.key.selectdata";
	// 选择页面 跳转回 输入页面 时，在request中保存数据的key
	public static final String REQUEST_KEY_RETURNVALUE =
		"request.key.return_value";
	public static String getValue(String key) {
		String value = (String) cache.get(key.toLowerCase());
		if (value != null) {
			value = value.trim();
		}
		return value;
	}
	public static int getIntValue(String key) {
		String value = getValue(key);
		int nValue = 0;
		try {
			nValue = Integer.parseInt(value);
		} catch (Exception e) {
		}
		return nValue;
	}
	public static void main(String[] args) {
		System.out.println(getValue("huawei.cfi.system.hibernate.config"));
	}
}